// pages/home/home.js
import {
  advertisementlist,
  teacherslist
} from '../../api/index'

import {
  get
} from '../../utils/http'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    background: ['demo-text-1', 'demo-text-2', 'demo-text-3'],
    indicatorDots: true,
    vertical: false,
    autoplay: true,
    interval: 1000,
    duration: 500,
    AdvertisementList: [],
    typeid: 1,
    TeachersList: []

  },
  // 轮播图
  async getadvertisementlist() {
    const res = await get(advertisementlist)
    // console.log(res);
    if (res.errCode == '10000') {
      this.setData({
        AdvertisementList: res.data.list
      })
    }
  },
  async getteacherslist() {
    const res = await get(teacherslist)
    // console.log(res);
    if (res.errCode == '10000') {
      this.setData({
        TeachersList: res.data.list
      })
    }
  },
  detail(e) {
    console.log(e);
    let id = e.currentTarget.dataset.id
    let name = e.currentTarget.dataset.name
    wx.navigateTo({
      url: '/pages/homedetail/homedetail?id=' + id + '&name=' + name,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getadvertisementlist()
    this.getteacherslist()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})